import type { PageResult } from '#/type/base_beans';
import type { SysTenantReq, SysTenantResp } from '#/type/sys_tenant';

import { requestClient } from '#/api/request';

const API_PREFIX = '/sys/tenant';

export async function getTenantByIdApi(id: string) {
  return requestClient.get<SysTenantResp>(`${API_PREFIX}/get_by_id/${id}`);
}

export async function getTenantListApi(params: SysTenantReq) {
  return requestClient.get<Array<SysTenantResp>>(`${API_PREFIX}/list`, {
    params,
  });
}

export async function getTenantPageApi(params: SysTenantReq) {
  return requestClient.get<PageResult<SysTenantResp>>(`${API_PREFIX}/page`, {
    params,
  });
}

export async function createTenantApi(data: SysTenantReq) {
  return requestClient.post<Promise<void>>(`${API_PREFIX}/create`, data);
}

export async function editTenantApi(data: SysTenantReq) {
  return requestClient.put<Promise<void>>(`${API_PREFIX}/edit`, data);
}

export async function createEditTenantApi(data: SysTenantReq) {
  return requestClient.post<Promise<void>>(`${API_PREFIX}/create_edit`, data);
}

export async function deleteTenantApi(ids: Array<string>) {
  return requestClient.delete<Promise<void>>(`${API_PREFIX}/delete`, {
    params: { ids },
  });
}
